package com.xiaoxx.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author HX
 * @Date 2022/3/9 14:12
 * TTL队列 配置文件
 */
@Configuration
public class QueueConfig {

    // 权限交换机
    public static final String ALI_CHAT_EXCHANGE = "ali_chat_exchange";
    //权限队列的名称
    public static final String ALI_CHAT = "ali_chat";


    //声明AUTH_EXCHANGE交换机
    @Bean
    public DirectExchange aliChatExchange() {
        return new DirectExchange(ALI_CHAT_EXCHANGE);
    }


    @Bean
    public Queue queueAliChat() {
        return new Queue(ALI_CHAT, true, false, false);
    }

    //声明QUEUE_LOGS普通队列

    /**
     * 队列绑定交换机
     *
     * @return
     */
    @Bean
    public Binding aBindingX() {
        return BindingBuilder.bind(queueAliChat()).to(aliChatExchange()).with("auth");
    }


    /**
     * 定义消息转换实例
     * @return
     */

//    @Bean
//    MessageHandlerMethodFactory messageHandlerMethodFactory(){
//        DefaultMessageHandlerMethodFactory messageHandlerMethodFactory = new DefaultMessageHandlerMethodFactory();
//        messageHandlerMethodFactory.setMessageConverter(mappingJackson2MessageConverter());
//        return messageHandlerMethodFactory;
//    }
//
//    @Bean
//    public MappingJackson2MessageConverter mappingJackson2MessageConverter() {
//        return new MappingJackson2MessageConverter();
//
//    }


}
